<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><![endif]-->
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>belanjasms.com - Jasa Pengiriman SMS</title>
        <meta name="description" content="jasa pengiriman sms" />
        <meta name="author" content="timesaver.co.id">
        <!-- Favicon-->
        <link rel="shortcut icon" href="<?= base_url("/static/favicon.png"); ?>" />		
        <!-- Bootstrap -->
        <link href="<?= base_url("/static/css/bootstrap.min.css"); ?>" rel="stylesheet">
        <!-- Template  -->
        <link href="<?= base_url("/static/css/templatemo_style.css"); ?>" rel="stylesheet">

        <script type="text/javascript" src="<?= base_url("/static/js/jquery.min.js"); ?>"></script>
        <script type="text/javascript" src="<?php echo base_url() ?>static/js/jquery-1.8.2.min.js"></script>
        <script src="<?= base_url("/static/js/bootstrap.min.js"); ?>"></script>
        <script src="<?= base_url("/static/js/jquery.easing.1.3.js"); ?>"></script>
        <script src="<?= base_url("/static/js/jquery.mobile.customized.min.js"); ?>"></script>
        <script src="<?= base_url("/static/js/unslider.min.js"); ?>"></script>
        <script src="<?= base_url("/static/js/jquery.singlePageNav.min.js"); ?>"></script>        
        <script src="<?= base_url("/static/js/templatemo_script.js"); ?>"></script>

        <!-- Dialog -->
        <link href="<?= base_url("/static/js/jquery-ui.min.css"); ?>" rel="stylesheet">
        <script src="<?= base_url("/static/js/jquery-ui.min.js"); ?>"></script>
        <script src="<?= base_url("/static/js/dialog.js"); ?>"></script>
    </head>
    <body>
        <div id="dialog-message" title="" style="display:none"></div>
        <div id="dialog-message-button" title="" style="display:none"></div>
        <div id="templatemo_contact" class="container_wapper">            
            <div class="container">
                <h2><?=$wording;?></h2><br>
                <div class="row">
                    <form id="prelogin" name="prelogin" action="<?php echo base_url(); ?>index.php/transaksi/smskit" method="post">                        
                        <div class="col-md-4">
                            <p>* No. Handphone</p>
                            <input type="text" name="phone" id="phone" value="<?=$phone;?>" />
                        </div> 
                        <div class="col-md-4">
                            <p>* Kata Sandi</p>
                            <input type="password" name="sandi" id="sandi" placeholder="Masukkan Kata Sandi" />
                        </div>
                        <input type="hidden" name="<?php echo $this->security->get_csrf_token_name(); ?>" value="<?php echo $this->security->get_csrf_hash(); ?>">                        
                    </form>
                    <form action="#">
                        <div class="col-md-4 col-xs-8">
                            <button id="login">Login</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        <div id="templatemo_footer" class="container_wapper">
            <div class="container">
                <div class="row">
                    <div class="col-xs-12">
                        <p>Copyright © 2015 timesaver.co.id</p>
                    </div>
                </div>
            </div>
        </div>

        <script>
            $(function() {

                $("#login").click(function(event) {
                    var v_phone = document.getElementById('phone').value;
                    var v_sandi = document.getElementById('sandi').value;

                    if (v_phone === "") {
                        show_alert("No. Handphone tidak boleh kosong");
                    } else if (v_sandi === "") {
                        show_alert("Kata Sandi tidak boleh kosong");
                    }
                    else
                    {
                        show_dialog("Silahkan tunggu, proses validasi user sedang dilakukan...");
                        $.ajax({
                            url: '<?php echo base_url(); ?>index.php/profile/cek_login',
                            type: "POST",
                            timeout: 15000,
                            data: {
                                phone: v_phone,
                                sandi: v_sandi,
                                '<?php echo $this->security->get_csrf_token_name(); ?>' : '<?php echo $this->security->get_csrf_hash(); ?>'
                            },
                            success: function(result)
                            {                                
                                var obres = $.parseJSON(result);
                                var err_code = obres.err_code;

                                if (err_code !== "00") {
                                    hide_dialog(obres.msg);
                                }
                                else
                                {
                                    hide_dialog("");
                                    $("#prelogin").submit();
                                }
                            },
                            error: function()
                            {
                                hide_dialog("Terdapat masalah dengan koneksi internet anda, silahkan coba kembali.");
                            }
                        });
                    }
                });
            });
        </script>
    </body>
</html>